// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_img;

import android.graphics.Bitmap;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import com.nnee.p_a.p_a.cls_e;
import com.nnee.p_b.p_a.cls_ad;
import com.nnee.p_b.p_a.cls_b;
import com.nnee.p_b.p_a.cls_g;
import com.nnee.p_fk.p_a.cls_a;
import com.nnee.p_fk.p_a.cls_l;
import com.nnee.p_fk.p_b.cls_c;
import com.nnee.p_pr.p_a.cls_p;
import com.nnee.p_pr.p_a.cls_r;
import java.lang.ref.SoftReference;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

// Referenced classes of package com.nnee.p_img:
//            e, c, f, a

public class cls_d
    implements  com.nnee.p_fk.p_b.cls_d
{

    private cls_d()
    {
        f = new HashMap();
        g = new HashMap();
        cls_l l1;
        if(Looper.myLooper() == null)
            d = new com.nnee.p_img. cls_e(this, Looper.getMainLooper());
        else
            d = new com.nnee.p_img. cls_e(this, Looper.myLooper());
        i = new cls_c();
        j = new cls_a();
        l1 = new cls_l(i, j);
        i.a(l1);
    }

    /**
     * @deprecated Method a is deprecated
     */

    public static cls_d a()
    {
        
        cls_d d1;
        if(h == null)
            h = new cls_d();
        d1 = h;
        
        return d1;
        
    }

    public static String a(String s, int i1, int j1)
    {
        if(i1 > 0 && j1 > 0)
        {
            String s1 = "";
            if(i1 > 0 && j1 > 0)
            {
                String s2 = (new StringBuilder()).append(s1).append("&w=").append(i1).toString();
                s1 = (new StringBuilder()).append(s2).append("&h=").append(j1).toString();
            }
            if(s1.length() > 0)
                s = (new StringBuilder()).append(s).append("%local").append(s1).toString();
        }
        return s;
    }

    private void a(int i1, int j1, Object obj)
    {
        d.obtainMessage(2, i1, j1, obj).sendToTarget();
    }

    private void a(int i1, Object obj)
    {
        if(obj != null){
        	 cls_b b1;
             String s;
             Bitmap bitmap;
             List list;
             String s1;
             b1 = (cls_b)obj;
             s = b1.a;
             bitmap = b1.c;
             if(s == null)
            	 return;
             list = b(s.hashCode());
             if(list == null)
            	 return;
             s1 = b(s);
             if(bitmap != null)
             {
            	 switch(b1.d)
                 {
                 case 0: // '\0'
                     a(list, s1, bitmap);
                     break;

                 case 1: // '\001'
                     Bitmap bitmap1 = com.nnee.p_img.cls_c.b(bitmap);
                     a(s, bitmap1, 1);
                     a(list, s1, bitmap1);
                     break;

                 case 2: // '\002'
                     a(s, bitmap, 2);
                     a(list, s1, bitmap);
                     break;
                 }
             }
             else
             {
             a(list, s1, ((Bitmap) (null)));
             }
        }
 
        return;
 
    }

    static void a(cls_d d1, int i1, cls_f f1)
    {
        d1.b(i1, f1);
    }

    static void a(cls_d d1, int i1, Object obj)
    {
        d1.a(i1, obj);
    }

    private void a(String s, int i1, cls_f f1, int j1, int k1, int l1, int i2)
    {
        cls_g g1 = com.nnee.p_b.p_a.cls_g.a(s, true, true, i1, j1, k1);
        g1.a(this);
        g1.b(l1);
        g1.c(i2);
        if(j1 > 0 && k1 > 0)
            s = (new StringBuilder()).append(s).append("%local&w=").append(j1).append("&h=").append(k1).toString();
        if(a(s.hashCode(), f1))
            i.a(g1);
    }

    private void a(String s, Bitmap bitmap, int i1)
    {
        if(bitmap != null && (i1 == 2 || i1 == 1))
        {
            Integer integer = Integer.valueOf(s.hashCode());
            f.put(integer, new SoftReference(bitmap));
        }
    }

    private void a(List list, String s, Bitmap bitmap)
    {
        for(Iterator iterator = list.iterator(); iterator.hasNext(); ((cls_f)iterator.next()).a(s, bitmap));
    }

    private Bitmap b(String s, int i1, int j1, int k1)
    {
        String s1 = a(s);
        Bitmap bitmap = null;
        if(!TextUtils.isEmpty(s1))
            bitmap = cls_p.a(s1);
        if(bitmap == null && (i1 == 2 || i1 == 1))
        {
            int l1 = s.indexOf("%local");
            if(l1 > 0)
            {
                String s2 = com.nnee.p_a.p_a.cls_e.a(cls_r.a(s.substring(0, l1)), false);
                if(s2 != null)
                    bitmap = cls_p.a(s2);
            }
        }
        a(s, bitmap, i1);
        return bitmap;
    }

    private String b(String s)
    {
        String s1;
        if(s == null)
            s1 = "";
        else
            s1 = String.valueOf(s.hashCode());
        return s1;
    }

    public static String b(String s, int i1, int j1)
    {
        return com.nnee.p_a.p_a.cls_e.a(cls_r.a(a(s, i1, j1)), false);
    }

    private List b(int i1)
    {
        Integer integer = Integer.valueOf(i1);
        HashMap hashmap = g;
 
        List list = (List)g.remove(integer);
        return list;
    }

    private void b(int i1, cls_f f1)
    {
        if(f1 != null)
            f1.a(String.valueOf(i1), null);
    }

    private void c(int i1, cls_f f1)
    {
        d.obtainMessage(1, i1, 0, f1).sendToTarget();
    }

    protected Bitmap a(String s, int i1)
    {
        SoftReference softreference = (SoftReference)f.get(Integer.valueOf(s.hashCode()));
        Bitmap bitmap;
        if(softreference != null)
            bitmap = (Bitmap)softreference.get();
        else
            bitmap = null;
        return bitmap;
    }

    public Bitmap a(String s, int i1, int j1, int k1)
    {
        if(i1 == 2 || i1 == 1)
        {
            String s1 = "";
            if(j1 > 0 || k1 > 0)
                s1 = (new StringBuilder()).append(s1).append("&w=").append(j1).toString();
            if(k1 > 0)
                s1 = (new StringBuilder()).append(s1).append("&h=").append(k1).toString();
            if(s1.length() > 0)
                s = (new StringBuilder()).append(s).append("%local").append(s1).toString();
        }
        Bitmap bitmap = a(s, i1);
        if(bitmap == null)
            bitmap = null;
        return bitmap;
    }

    public String a(String s)
    {
        String s1;
        if(s == null)
            s1 = null;
        else
            s1 = com.nnee.p_a.p_a.cls_e.a(cls_r.a(s), false);
        return s1;
    }

    public void a(int i1)
    {
        if(i1 > 0)
            i.b(i1);
    }

    public void a(int i1, int j1)
    {
        if(i1 > 0)
        {
            cls_ad ad1 = cls_ad.a(i1, j1);
            ad1.b(4);
            i.a(ad1);
        }
    }

    public void a(int i1, int j1, int k1, Object obj)
    {
        a(k1, i1, obj);
    }

    public void a(String s, int i1, int j1, int k1, int l1, com.nnee.p_fk.p_b.cls_d d1)
    {
        if(s != null)
        {
            cls_g g1 = com.nnee.p_b.p_a.cls_g.a(s, false, false, 0, i1, j1);
            g1.b(k1);
            g1.c(l1);
            if(d1 != null)
                g1.a(d1);
            i.a(g1);
        }
    }

    public void a(StringBuilder stringbuilder, int i1, String s, cls_f f1, int j1, int k1)
    {
        a(stringbuilder, i1, s, f1, -1, -1, j1, k1);
    }

    public void a(StringBuilder stringbuilder, int i1, String s, cls_f f1, int j1, int k1, int l1)
    {
        a(stringbuilder, i1, s, f1, j1, k1, l1, 0);
    }

    public void a(StringBuilder stringbuilder, int i1, String s, cls_f f1, int j1, int k1, int l1, 
            int i2)
    {
        a(stringbuilder, i1, s, f1, j1, k1, l1, i2, true);
    }

    public void a(StringBuilder stringbuilder, int i1, String s, cls_f f1, int j1, int k1, int l1, 
            int i2, boolean flag)
    {
        if(f1 != null) {
        	 String s1 = a(s, j1, k1);
             String s2 = b(s1);
             if(stringbuilder != null)
                 stringbuilder.append(s2);
             if(TextUtils.isEmpty(s))
             {
                 switch(i1)
                 {
                 case 0: // '\0'
                     f1.a(s2, null);
                     break;

                 case 1: // '\001'
                     f1.a(s2, null);
                     break;
                 }
             } else
             {
                 Bitmap bitmap = a(s1, i1);
                 if(bitmap != null)
                 {
                     switch(i1)
                     {
                     case 0: // '\0'
                         if(j1 > 0 && k1 > 0)
                             f1.a(s2, com.nnee.p_img.cls_c.b(bitmap, j1, k1));
                         else
                             f1.a(s2, bitmap);
                         break;

                     case 1: // '\001'
                         f1.a(s2, bitmap);
                         break;

                     case 2: // '\002'
                         f1.a(s2, bitmap);
                         break;
                     }
                 } else
                 {
                     if(!flag)
                         bitmap = b(s1, i1, j1, k1);
                     if(bitmap != null)
                         switch(i1)
                         {
                         case 0: // '\0'
                             f1.a(s2, bitmap);
                             break;

                         case 1: // '\001'
                             Bitmap bitmap1 = com.nnee.p_img.cls_c.a(bitmap);
                             f1.a(s2, bitmap1);
                             a(s1, bitmap1, i1);
                             break;

                         case 2: // '\002'
                             f1.a(s2, bitmap);
                             a(s1, bitmap, i1);
                             break;
                         }
                     else
                         a(s, i1, f1, j1, k1, l1, i2);
                 }
             }
        }
 
         
    }

    protected boolean a(int i1, cls_f f1)
    {
        Integer integer;
        if(f1 == null)
            return false;
        integer = Integer.valueOf(i1);
        HashMap hashmap = g;
         
        List list = (List)g.get(integer);
        if(list != null) {
        	if(list.contains(f1))
        		return true;
            list.add(f1);
            
            return true;
        } else {
        	LinkedList linkedlist = new LinkedList();
            linkedlist.add(f1);
            g.put(integer, linkedlist);
            
            return true;
        }
 
    }

    public void b()
    {
    }

    public void b(int i1, int j1, int k1, Object obj)
    {
        if(obj != null)
        {
            List list = b(obj.hashCode());
            if(list != null)
            {
                Iterator iterator = list.iterator();
                do
                {
                    if(!iterator.hasNext())
                        break;
                    cls_f f1 = (cls_f)iterator.next();
                    if(f1 instanceof  com.nnee.p_img.cls_a)
                        c(((String)obj).hashCode(), f1);
                } while(true);
            }
        }
    }

    public void c()
    {
        f.clear();
        if(i != null)
        {
            i.b();
            i = null;
        }
        if(j != null)
        {
            j.a();
            j = null;
        }
        h = null;
    }

    public cls_c d()
    {
        return i;
    }

    public void e()
    {
        f.clear();
    }

    public void f()
    {
        g();
        i.d();
    }

    public void g()
    {
        HashMap hashmap = g;
        
        g.clear();
        return;
    }

    public static final int a = 0;
    public static final int b = 1;
    public static final int c = 2;
    static final String e = "ImageManager";
    private static cls_d h;
    private static final int k = 1;
    private static final int l = 2;
    Handler d;
    private Map f;
    private HashMap g;
    private cls_c i;
    private cls_a j;
}
